#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int ret = 0;
    int tar = 0;
    vector<int> sumNums;
    int findTargetSumWays(vector<int>& nums, int target) {
        tar = target;
        sumNums = nums;
        dfs(0, 0);

        return ret;
    }

    void dfs(int i, int path)
    {
        if (i == sumNums.size())
        {
            if (path == tar)
            {
                ret++;
            }

            return;
        }
        dfs(i + 1, path + sumNums[i]);
        dfs(i + 1, path - sumNums[i]);

    }
};